from django.db import models


class Judgement(models.Model):
    order_id = models.IntegerField(primary_key=True)
    releaser_id = models.IntegerField(blank=True, null=True)
    judged_id = models.IntegerField(blank=True, null=True)
    judgement_info = models.CharField(max_length=100, blank=True, null=True)
    score = models.FloatField(blank=True, null=True)
    belief_score = models.FloatField(blank=True, null=True)
    release_time = models.DateTimeField(null=True)

    class Meta:
        managed = True
        db_table = 'judgement'


class Order(models.Model):
    id = models.IntegerField(primary_key=True)
    customer_id = models.IntegerField(blank=True, null=True)
    real_worker_id = models.IntegerField(blank=True, null=True)
    condition = models.IntegerField(blank=True, null=True)
    price = models.FloatField(blank=True, null=True)
    description = models.CharField(max_length=1000, blank=True, null=True)
    type = models.CharField(max_length=20, blank=True, null=True)
    start_time = models.DateTimeField(null=True)
    end_time = models.DateTimeField(null=True)
    release_time = models.DateTimeField(null=True)
    title = models.CharField(max_length=50, blank=True, null=True)
    date = models.CharField(max_length=20, blank=True, null=True)
    duration = models.CharField(max_length=20, blank=True, null=True)
    longitude = models.FloatField(null=True)
    latitude = models.FloatField(null=True)
    score = models.IntegerField(null=True)
    requirement = models.CharField(max_length=10, blank=True, null=True)
    gender_requirement = models.CharField(max_length=10, blank=True, null=True)
    demand = models.TextField(null=True)
    class Meta:
        managed = True
        db_table = 'order'


class UserInfo(models.Model):
    id = models.IntegerField(primary_key=True)
    phone = models.CharField(max_length=13, blank=True, null=True)
    id_card = models.CharField(max_length=20, blank=True, null=True)
    score = models.FloatField(blank=True, null=True)
    belief_score = models.FloatField(blank=True, null=True)
    name = models.CharField(max_length=10, blank=True, null=True)
    nick_name = models.CharField(max_length=20, blank=True, null=True)
    age = models.IntegerField(blank=True, null=True)
    signature = models.TextField(blank=True, null=True)
    gender = models.CharField(max_length=10, blank=True, null=True)
    area = models.JSONField(blank=True, null=True)
    avatar = models.TextField(blank=True, null=True)
    password = models.TextField(max_length=45, null=True)
    type = models.JSONField(blank=True, null=True)
    career = models.CharField(max_length=10, blank=True, null=True)
    lowest_wage = models.FloatField(blank=True, null=True)
    highest_wage = models.FloatField(blank=True, null=True)
    profile = models.TextField(blank=True, null=True)

    class Meta:
        managed = True
        db_table = 'user_info'


class WantToWorker(models.Model):
    order_id = models.IntegerField(blank=True, null=True)
    want_to_worker_id = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = True
        db_table = 'want_to_worker'

class Report(models.Model):
    title = models.TextField(blank=True, null=True)
    describe = models.TextField(blank=True, null=True)
    phone = models.CharField(max_length=50, null=True)
    name = models.CharField(max_length=20, null=True)

    class Meta:
        managed = True
        db_table = 'report'

# 聊天记录
class ChatMessage(models.Model):
    id = models.IntegerField(primary_key=True)  # 每条消息的唯一标识符
    sender = models.IntegerField(null=False)  # 发送用户
    receiver = models.IntegerField(null=False)  # 接收用户
    content = models.TextField()  # 聊天消息内容
    timestamp = models.CharField(max_length=50, null=True)  # 时间
    group = models.IntegerField(null=True)  # 消息群组
    read = models.BooleanField(null=True)  # 消息是否已读

    class Meta:
        managed = True
        db_table = 'chat_message'


# 聊天群组
class ChatGroup(models.Model):
    id1 = models.IntegerField(null=True)
    id2 = models.IntegerField(null=True)
    order_id = models.IntegerField(null=True)
    group = models.IntegerField(null=True)
    top = models.BooleanField(default=False)

    class Meta:
        managed = True
        db_table = 'chat_group'


class Code(models.Model):
    id1 = models.IntegerField(null=True)
    code_1 = models.CharField(max_length=12, null=True)
    id = models.IntegerField(primary_key=True)  # 每条消息的唯一标识符

    class Meta:
        managed = True
        db_table = 'code'

class Session(models.Model):
    id=models.IntegerField(primary_key=True)
    userid=models.IntegerField(max_length=13,null=True)

    class Meta:
        managed = True
        db_table = 'session'
